home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Development
/
General
/
MM3Tp.sea Folder
/
Made by Marksman
/
Sources
/
mm
/
mmMenuMM_Demo.p
< prev
next >
Wrap
Text File
|
1994-01-16
|
10KB
|
343 lines
Unit mmMenuMM_Demo;
{ Copyright © 1994 George R. Cossey }
{ mmMenuMM_Demo Handle menus
File name: mmMenuMM_Demo
Function: This contains the routines to handle menus.
History: 1/16/94 Original by George Cossey
}
interface
uses
Printing,Folders,Sound,mmCommonMM_Demo,CommonMM_Demo,
UeventsMM_Demo,{}
mmPA_My_Alert,
{}
mmD_My_Modal,
{}
mmMD_My_Movable_Moda,
mmMD_My_Modeless,
mmMD_About_Demo,
{}
mmW_My_basic_window,
mmW_Floating_window,
{}
UmenuMM_Demo;
procedure Init_My_Menus;
procedure Handle_My_Menu(theMenu,theItem:integer);
{NOTE: This routine is in this file to allow access to it by routines in the Common file}
{ If this routine were in Main then it would not link properly}
procedure DoActivate;
{ ======================================================= }
{ ======================================================= }
implementation
{ ======================================================= }
{ ======================================================= }
{ Routine: DoActivate }
{ Purpose: Got an activate or deactivate event }
procedure DoActivate;
var
whichWindow:WindowPtr; { See which window for event }
Do_An_Activate:Boolean; { Flag to pass }
theRefCon:longint; { Refcon with layer masked off }
begin
whichWindow := WindowPtr(myEvent.message); { Get the window the update is for }
Do_An_Activate := (BAND(myEvent.modifiers,$0001) <> 0);{ Make sure it is Activate and not DeActivate }
theRefCon := GetWRefCon(whichWindow); { Get the refcon }
theRefCon := BAND(theRefCon,$00FFFFFF); { Mask the layer out }
case (theRefCon) of { Do the appropiate window }
-1:begin end;
ResW_My_basic_window:
Activate_My_basic_window(whichWindow,Do_An_Activate); { Activate or deactivate this window }
ResW_Floating_window:
Activate_Floating_window(whichWindow,Do_An_Activate); { Activate or deactivate this window }
otherwise { allow other buttons, trap for debug }
U_Activate(whichWindow,Do_An_Activate); { Allow user to handle others }
end; { end of switch }
end;
{ ======================================================= }
{ Routine: Init_My_Menus }
{ Purpose: Load in the menu lists and initialize the menubar }
procedure Init_My_Menus;
begin
ClearMenuBar; { Clear any old menu bars }
{ This menu is }
Menu_Apple := GetMenu(Res_Menu_Apple); { Get the menu from the resource file }
InsertMenu(Menu_Apple,0); { Insert this menu into the menu bar }
AddResMenu(Menu_Apple,'DRVR'); { Add in DAs }
{ This menu is File }
Menu_File := GetMenu(Res_Menu_File); { Get the menu from the resource file }
InsertMenu(Menu_File,0); { Insert this menu into the menu bar }
{ This menu is Edit }
Menu_Edit := GetMenu(Res_Menu_Edit); { Get the menu from the resource file }
InsertMenu(Menu_Edit,0); { Insert this menu into the menu bar }
{ This menu is Windows }
Menu_Windows := GetMenu(Res_Menu_Windows); { Get the menu from the resource file }
InsertMenu(Menu_Windows,0); { Insert this menu into the menu bar }
AddExtraMenus; { Add any extra menu lists }
DrawMenuBar; { Draw the menu bar }
end;
{ ======================================================= }
{ Routine: DoMenuApple }
{ Purpose: Handle all menu items in this list }
procedure DoMenuApple(theItem: integer);
var
SkipProcessing:Boolean; { TRUE says skip processing }
DNA:integer; { For opening DAs }
DAName:Str255; { For getting DA name }
SavePort:GrafPtr; { Save current port when opening DAs }
begin
SkipProcessing := false; { Set to not skip the processing of this menu item }
Do_AppleMenu(true,theItem,SkipProcessing); { Pre menu handler }
if (not(SkipProcessing)) then { See if process the menu list }
begin
case (theItem) of { Handle all commands in this menu list }
-1:begin end;
MItem_About_Demo: { For item About Demo… }
begin
Add_UserEvent(UserEvent_Open_Window,ResD_About_Demo,0,0,nil); { Open this modeless dialog }
end;
otherwise { allow other buttons, trap for debug }
begin
GetPort(SavePort); { Save the current port }
GetItem(Menu_Apple,theItem,DAName); { Get the name of the DA selected }
DNA := OpenDeskAcc(DAName); {Open the DA selected }
SetPort(SavePort); { Restore to the saved port }
end; { end of otherwise }
end; { end of switch }
end;
Do_AppleMenu(false,theItem,SkipProcessing); { Post menu handler }
end;
{ ======================================================= }
{ Routine: DoMenuFile }
{ Purpose: Handle all menu items in this list }
procedure DoMenuFile(theItem: integer);
var
SkipProcessing:Boolean; { TRUE says skip processing }
begin
SkipProcessing := false; { Set to not skip the processing of this menu item }
Do_FileMenu(true,theItem,SkipProcessing); { Pre menu handler }
if (not(SkipProcessing)) then { See if process the menu list }
begin
case (theItem) of { Handle all commands in this menu list }
-1:begin end;
MItem_New: { For item New }
begin
end;
MItem_Open: { For item Open… }
begin
Open_The_File; { Do file open }
end;
MItem_Close: { For item Close }
begin
end;
MItem_Save: { For item Save }
begin
Save_The_File; { Do file save }
end;
MItem_Save_As: { For item Save As… }
begin
Save_The_File; { Do file save }
end;
MItem_Revert: { For item Revert }
begin
end;
MItem_Page_Setup: { For item Page Setup… }
begin
PageSetup; { Do Printing PageSetup }
end;
MItem_Print: { For item Print… }
begin
Print_The_Data; { Do Printing }
end;
MItem_Quit: { For item Quit }
begin
doneFlag := true; { Quit }
end;
otherwise { allow other buttons, trap for debug }
begin
end; { end of otherwise }
end; { end of switch }
end;
Do_FileMenu(false,theItem,SkipProcessing); { Post menu handler }
end;
{ ======================================================= }
{ Routine: DoMenuEdit }
{ Purpose: Handle all menu items in this list }
procedure DoMenuEdit(theItem: integer);
var
SkipProcessing:Boolean; { TRUE says skip processing }
BoolHolder:Boolean; { For SystemEdit result }
begin
SkipProcessing := false; { Set to not skip the processing of this menu item }
Do_EditMenu(true,theItem,SkipProcessing); { Pre menu handler }
if (not(SkipProcessing)) then { See if process the menu list }
begin
BoolHolder := SystemEdit(theItem - 1); { Let the DA do the edit to itself }
if (not(BoolHolder)) then { If not a DA then we get it }
begin
case (theItem) of { Handle all commands in this menu list }
-1:begin end;
MItem_Undo: { For item Undo }
begin
end;
MItem_Cut: { For item Cut }
begin
end;
MItem_Copy: { For item Copy }
begin
end;
MItem_Paste: { For item Paste }
begin
end;
MItem_Clear: { For item Clear }
begin
end;
MItem_Select_All: { For item Select All }
begin
end;
otherwise { allow other buttons, trap for debug }
begin
end; { end of otherwise }
end; { end of switch }
end;
end;
Do_EditMenu(false,theItem,SkipProcessing); { Post menu handler }
end;
{ ======================================================= }
{ Routine: DoMenuWindows }
{ Purpose: Handle all menu items in this list }
procedure DoMenuWindows(theItem: integer);
var
SkipProcessing:Boolean; { TRUE says skip processing }
begin
SkipProcessing := false; { Set to not skip the processing of this menu item }
Do_WindowsMenu(true,theItem,SkipProcessing); { Pre menu handler }
if (not(SkipProcessing)) then { See if process the menu list }
begin
case (theItem) of { Handle all commands in this menu list }
-1:begin end;
MItem_Alert: { For item Alert… }
begin
PA_My_Alert; { Open this alert }
end;
MItem_Modal_Dialog: { For item Modal Dialog… }
begin
MPD_My_Modal; { Open this modal dialog }
end;
MItem_Movable_Modal_D: { For item Movable Modal Dialog… }
begin
Add_UserEvent(UserEvent_Open_Window,ResD_My_Movable_Moda,0,0,nil); { Open this modeless dialog }
end;
MItem_Modeless_Dialog: { For item Modeless Dialog… }
begin
Add_UserEvent(UserEvent_Open_Window,ResD_My_Modeless,0,0,nil); { Open this modeless dialog }
end;
MItem_Window: { For item Window… }
begin
Add_UserEvent(UserEvent_Open_Window,ResW_My_basic_window,0,0,nil); { Open this window }
end;
MItem_Floating_window: { For item Floating window… }
begin
Add_UserEvent(UserEvent_Open_Window,ResW_Floating_window,0,0,nil); { Open this window }
end;
otherwise { allow other buttons, trap for debug }
begin
end; { end of otherwise }
end; { end of switch }
end;
Do_WindowsMenu(false,theItem,SkipProcessing); { Post menu handler }
end;
{ ======================================================= }
{ ======================================================= }
{ Routine: Handle_My_Menu }
{ Purpose: Vector off to the appropiate menu list handler }
procedure Handle_My_Menu(theMenu,theItem:integer);
begin
case (theMenu) of { Do selected menu list }
-1:begin end;
Res_Menu_Apple:
DoMenuApple(theItem); { Go handle this list, }
Res_Menu_File:
DoMenuFile(theItem); { Go handle this list, File }
Res_Menu_Edit:
DoMenuEdit(theItem); { Go handle this list, Edit }
Res_Menu_Windows:
DoMenuWindows(theItem); { Go handle this list, Windows }
otherwise { allow other buttons, trap for debug }
Handle_Other_Menus(theMenu,theItem); { Handle other special menus }
end; { end of switch }
HiliteMenu(0); { Turn menu selection off }
end;
{ ======================================================= }
{ ======================================================= }
end.